import { BusinessStatus } from '~/src/enum';
import { request } from '../../request';

export function fetchRolePage(page: Common.Page<SysAuth.RoleInfo>, searchData: any) {
  return request({
    url: '/sys/role/list',
    data: { page, searchData },
    method: 'POST',
  });
}

export function fetchRole(id: Common.IdType) {
  return request({
    url: `/sys/role/${id}`,
    method: 'GET',
  });
}

export function fetchRoleSelect() {
  return request({
    url: '/sys/role/select',
    method: 'GET',
  });
}

export function fetchAddRole(data: SysAuth.RoleInfo) {
  return request({
    url: '/sys/role/',
    data: data,
    method: 'POST',
  });
}

export function fetchUpdateRole(data: SysAuth.RoleInfo) {
  return request({
    url: '/sys/role/',
    data: data,
    method: 'PUT',
  });
}

export function fetchUpdateRoleStatus(id: Common.IdType, status: BusinessStatus) {
  return request({
    url: `/sys/role/status/${id}/${status}`,
    method: 'PUT',
  });
}

export function fetchRemoveRoles(ids: Common.IdType[]) {
  return request({
    url: `/sys/role/${ids}`,
    method: 'DELETE',
  });
}

